package com.controller;

import com.feign.UserFeign;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class UserController {

    @Resource
    private RestTemplate restTemplate;

    @Resource
    private DiscoveryClient discoveryClient;

    @Resource
    private UserFeign userFeign;

    @RequestMapping("/getUser")
    public Map<String, String> getMap() {
        return restTemplate.getForObject("http://PROVIDER/getMap", Map.class);
    }

    @RequestMapping("/getUser.do")
    public Map<String, String> getMap1() {
        List<String> services = discoveryClient.getServices();
        for (String service : services) {
            System.out.println(service);
        }
        return userFeign.getMap();
    }
}
